import { t } from "@/locales";
import {FormRule, PrimaryTableCol, Tag, SelectProps} from "tdesign-vue-next";

/**
 * 搜索表单项
 */
export const searchParams: SearchParamsProps[] = [
    {
        label: t('pages.sysRole.name'),
        key: 'name',
    },
    {
        label: t('pages.sysRole.code'),
        key: 'code',
    }
];

/**
 * 表格列
 */
export const columns: PrimaryTableCol[] = [
    {
        title: t('pages.sysRole.name'),
        ellipsis: true,
        align: 'center',
        colKey: 'name',
    },
    {
        title: t('pages.sysRole.code'),
        ellipsis: true,
        align: 'center',
        colKey: 'code',
    },
    {
        title: t('pages.sysRole.status'),
        ellipsis: true,
        align: 'center',
        colKey: 'status',
        cell: (h, {row}) => h(Tag, { theme: row.status == 0 ? 'primary': 'danger' }, t(`components.isSetup.${row.status == 0 ? 'on' : 'off'}`))
    },
    {
        title: t('pages.sysRole.remarks'),
        ellipsis: true,
        align: 'center',
        colKey: 'remarks',
    },
];

/**
 * 表单校验规则
 */
export const rules: Record<string, FormRule[]> = {
    name: [{required: true, message: t('pages.sysRole.required.name'), type: 'error', trigger: 'blur'}],
    code: [{required: true, message: t('pages.sysRole.required.code'), type: 'error', trigger: 'blur'}],
}

export const statusOptions: SelectProps['options'] = [
    {
        label: t(`components.isSetup.on`),
        value: 0
    },
    {
        label: t(`components.isSetup.off`),
        value: 1
    },
]
